<template>
  <el-container style="padding: 0;height: 100vh;width: 100%">
    <el-header class="header">
      <el-row style="width: 100%; display: flex; align-items: center;">
        <el-col :span="4" style="display: flex; align-items: center;">
          <img class="logo" src="@/assets/lightning-9075_512.gif" style="height: 50px;">
          <div style="padding-left: 10px;">
            <h3 style="color: white;">石家庄预警中台</h3>
          </div>
        </el-col>
        <el-col :span="1" :offset="19" style="display: flex; align-items: center;">
          <el-dropdown>
            <el-button icon="el-icon-user" circle></el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-col>
      </el-row>
    </el-header>
    <el-main style="padding: 0;height: 100%">
      <el-container style="padding: 0;background-color: #edf2fa;height: 100%">
        <el-aside style="height: 100%;max-width: 230px">
          <el-menu :default-active="$route.path" class="el-menu-vertical-demo"
                   active-text-color="#409EFF" style="border: none" @select="handleRouter">
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-s-home"></i>
                <span slot="title">预警中心</span>
              </template>
              <el-menu-item index="/map" style="display: flex;align-items: center">
                <el-icon class="el-icon-alarm-clock"></el-icon>
                模型外推
              </el-menu-item>
            </el-submenu>
            <el-submenu index="/data">
              <template slot="title">
                <i class="el-icon-data-analysis"></i>
                <span slot="title">数据中台</span>
              </template>
              <el-menu-item index="/history" style="display: flex;align-items: center">
                <el-icon class="el-icon-s-release"></el-icon>
                历史统计
              </el-menu-item>
              <el-menu-item index="/stationData" style="display: flex;align-items: center">
                <el-icon class="el-icon-data-line"></el-icon>
                站点数据
              </el-menu-item>
            </el-submenu>
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-s-data"></i>
                <span slot="title">产品解析</span>
              </template>
              <el-menu-item index="/CR" style="display: flex;align-items: center">
                <el-icon class="el-icon-document"></el-icon>
                CR
              </el-menu-item>
              <el-menu-item index="/ET" style="display: flex;align-items: center">
                <el-icon class="el-icon-document"></el-icon>
                ET
              </el-menu-item>
              <el-menu-item index="/TREF" style="display: flex;align-items: center">
                <el-icon class="el-icon-document"></el-icon>
                TREF
              </el-menu-item>
              <el-menu-item index="/RHO" style="display: flex;align-items: center">
                <el-icon class="el-icon-document"></el-icon>
                RHO
              </el-menu-item>
              <!--            <el-menu-item index="/VIL" style="display: flex;align-items: center">-->
              <!--              <el-icon class="el-icon-document"></el-icon>-->
              <!--              VIL-->
              <!--            </el-menu-item>-->
              <el-menu-item index="/ZDR" style="display: flex;align-items: center">
                <el-icon class="el-icon-document"></el-icon>
                ZDR
              </el-menu-item>
              <el-menu-item index="/KDP" style="display: flex;align-items: center">
                <el-icon class="el-icon-document"></el-icon>
                KDP
              </el-menu-item>
              <el-menu-item index="/PHI" style="display: flex;align-items: center">
                <el-icon class="el-icon-document"></el-icon>
                PHI
              </el-menu-item>
              <el-menu-item index="/REF" style="display: flex;align-items: center">
                <el-icon class="el-icon-document"></el-icon>
                REF
              </el-menu-item>

            </el-submenu>
            <el-menu-item index="/EC">
              <i class="el-icon-menu"></i>
              <span slot="title">模式预报</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-container style="padding: 0;margin: 0;height: 100%">
          <el-main style="padding: 0;margin: 0;height: 100%">
            <!--        地图图层相关展示组件-->
            <router-view></router-view>
          </el-main>
          <!--      控制右侧面板展示的组件-->
          <CollapseIcon></CollapseIcon>
        </el-container>
      </el-container>
    </el-main>
  </el-container>
</template>

<script>
import CollapseIcon from "@/components/CollapseIcon";
import {removeToken} from "@/utils/auth";
import { MessageBox } from 'element-ui'
export default {
  name: "mainPage",
  components: {CollapseIcon},
  data() {
    return {
      defaultactive: "1",
      activeIndex: "1",
      coll: false
    }
  },
  methods: {
    handleRouter(key, keyPath) {
      if (this.$route.path === key) {
        return
      }
      this.$router.push(key)
    },
    logout() {
      MessageBox.confirm('确定退出登录吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        removeToken()
        this.$router.push('/')
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消退出'
        })
      })
    }
  },
  mounted() {
  }
}
</script>

<style scoped>
.title {
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  margin-left: 10px;
  gap: 10px;
}

.header {
  background-color: #409eff;
  display: flex;
  align-items: center;
  /*background-image: url('~@/assets/weather-1615103_1920.jpg');*/
  /*background-size: cover;*/
  /*background-position: center;*/
  /*background-repeat: no-repeat;*/
}

</style>